package com.h3c.nem.controller;

import com.eos.common.constant.StatusCodeEnum;
import com.eos.common.util.Result;
import com.h3c.nem.service.ISapSyncService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * sap控制层
 *
 * @author chenyifan
 * @date 2022/6/8 14:33
 */
@Slf4j
@CrossOrigin
@RestController
@AllArgsConstructor
@RequestMapping("/sapSync")
public class SapSyncController {

    private final ISapSyncService sapSyncService;
    /**
     * 根据员工预备工号同步BPM预备员工
     *
     * @param workerId 预备工号
     * @return
     */
    @GetMapping("/getReserveStaff")
    public Result<String> getReserveStaff(String workerId) {
        try {
            sapSyncService.getReserveStaff(workerId);
            return new Result(true, StatusCodeEnum.NORMAL);
        } catch (Exception e) {
            log.error("预备工号为："+workerId+"sap同步失败，原因:{}",e.getMessage());
            return new Result(false, 400, e.getMessage());
        }
    }
}
